<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .section1:not(:has(h1, h2, h3, h4, h5, h6)) {
      span {
        color: red;
      }
    }
    /* 至少有一个不是h1 */
    .section2:has(:not(h1, h2, h3, h4, h5, h6)) {
      span {
        color:pink;
      }
      h6 {
        color: blue;
      }
    }
  </style>
</head>
<body>
  <section class="section1">
    <h1></h1>
    <span>我是第一个section1，我有h1</span>
  </section>
  <section class="section1">
    <span>我是第二个section1 我能被选中，我没有h1~h6</span>
  </section>
  <section class="section2">
    <h1></h1>
    <h2></h2>
    <h3></h3>
    <h4></h4>
    <h5></h5>
    <h6>我是h6标签</h6>
    <span>我是第一个section2</span>
  </section>
  <section class="section2">
    <span>我是第二个section2</span>
  </section>
</body>
</html>